package violin.web.results;

import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.io.json.JettisonMappedXmlDriver;
import static violin.Configuration.resolveClassAlias;

public class JsonResult {
    private final Object objectValue;

    public JsonResult(Object objectValue) {
        this.objectValue = objectValue;
    }

    public String toString() {
        XStream xstream = new XStream(new JettisonMappedXmlDriver());
        xstream.setMode(XStream.NO_REFERENCES);
        xstream.alias(resolveClassAlias(objectValue.getClass()), objectValue.getClass());
        return xstream.toXML(objectValue);
    }
}
